<?php

namespace System\library\error\observers;

use System\library\Logger;

/**
 * <b>Class</b> :        Display<br>
 * <b>Fonction</b> :     Observer "log" permet de logger une erreur ou une exception
 * <br>
 * @version              1.0
 * @author               Dread <dreadlokeur@gmail.com>
 * @license              Licence publique générale GNU http://www.gnu.org/licenses/gpl.html
 * @copyright            Copyright 2011 - MidichloriansPHP and contributors
 * @package              System
 * @subpackage           library\library\error\observers
 *
 * @see \SplObserver
 */
class Log implements \SplObserver {

    public function __construct() {

    }

    public function update(\SplSubject $subject, $isException = false) {
        if (!$isException) {
            $error = $subject->getError();
            Logger::getInstance()->error($error->type . ' : "' . $error->message . '" in ' . $error->file . ' on line ' . $error->line);
        } else {
            $exception = $subject->getException();
            Logger::getInstance()->error($exception->type . ' : "' . $exception->message . '" in ' . $exception->file . ' on line ' . $exception->line);
        }
    }

}

?>
